#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

char* addStrings(char* num1, char* num2)
{
    int len1 = strlen(num1) - 1;
    int len2 = strlen(num2) - 1;
    char* sum = (char*)malloc((fmax(len1, len2) + 3) * sizeof(char));
    int mid = 0;
    int i = 0;
    while (len1 >= 0 || len2 >= 0 || mid != 0)
    {
        int a = len1 >= 0 ? num1[len1] - '0' : 0;
        int b = len2 >= 0 ? num2[len2] - '0' : 0;
        int count = a + b + mid;
        sum[i++] = '0' + count % 10;
        mid = count / 10;
        len1--;
        len2--;
    }

    for (int j = 0; 2 * j < i; j++)
    {
        int temp = sum[j];
        sum[j] = sum[i - j - 1];
        sum[i - j - 1] = temp;
    }
    sum[i++] = 0;
    return sum;
}